package com.example.cp.mvvm.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

public abstract class BaseActivity  <VDB extends ViewDataBinding,VM extends ViewModel> extends AppCompatActivity {
    protected VDB binding;
    protected VM viewModel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,bindLoutId());
        viewModel = new ViewModelProvider(this).get(getViewModel());
        initView();
        initData();
    }
    public abstract void initView();
    public abstract void initData();
    public abstract int bindLoutId();
    public abstract Class<VM> getViewModel();
}
